package com.example.pc.mycreateview;

import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.widget.Toast;
import com.example.pc.mycreateview.listener.MyViewClick;
import com.example.pc.mycreateview.view.TopBarView;

public class MainActivity extends AppCompatActivity {

    private TopBarView topBarView;

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);

        initView();
    }

    private void initView() {
        topBarView=findViewById(R.id.mTopBar);
        topBarView.setLeftVisibility(false);
        topBarView.setRightVisibility(false);
        topBarView.setRightImageVisibility(true);
        topBarView.setLeftImageVisibility(false);
        topBarView.setBackgroundTitle(getResources().getColor(R.color.colorPrimary));


        topBarView.setMyViewClick(new MyViewClick() {
            @Override
            public void leftClick() {
                Toast.makeText(MainActivity.this, "左", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void rightClick() {
                Toast.makeText(MainActivity.this, "右", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void titleClick() {
                Toast.makeText(MainActivity.this, "center", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void leftImageClick() {
                Toast.makeText(MainActivity.this, "image左", Toast.LENGTH_SHORT).show();
            }

            @Override
            public void rightImageClick() {
                Toast.makeText(MainActivity.this, "image右", Toast.LENGTH_SHORT).show();
            }
        });
    }
}
